package com.yuanhua.xcxmng.wechat.init;

import cn.hutool.cron.CronUtil;
import com.yuanhua.xcxmng.wechat.job.ConfirmTargetTask;
import com.yuanhua.xcxmng.wechat.job.UpdateLastDayStepTask;
import com.yuanhua.xcxmng.wechat.job.UpdateNoTask;
import com.yuanhua.xcxmng.wechat.job.UpdateStepTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class MyCommandLineRunner implements CommandLineRunner {

    @Autowired
    private UpdateNoTask          updateNoTask;

    @Autowired
    private UpdateLastDayStepTask updateLastDayStepTask;

    @Autowired
    private ConfirmTargetTask     confirmTargetTask;

    @Autowired
    private UpdateStepTask        updateStepTask;

    @Override
    public void run(String... strings) throws Exception {
        //支持秒级别定时任务
        CronUtil.setMatchSecond(true);
        CronUtil.start();
        CronUtil.schedule("* */2 * * *", updateNoTask);
        CronUtil.schedule("0 50 23 * * ?", updateLastDayStepTask);
        CronUtil.schedule("0 30 22 * * ?", confirmTargetTask);
        CronUtil.schedule("0 0 0 * * ?", updateStepTask);
    }
}
